   // 迭代
   vector<int> inorderTraversal(TreeNode* root) {
        stack<TreeNode*> s;
        vector<int> res;
        TreeNode* cur = root;
        while(cur != nullptr || !s.empty()){
            if(cur != nullptr){   // 访问到最底层
                s.push(cur);
                cur = cur->left;
            }else{
                cur = s.top();
                s.pop();
                res.push_back(cur->val);
                cur = cur->right;
            }
        }

        return res;
    }